package com.buyhouse.zhaimao;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;

/**
 * Fragment基类
 * 
 * @author zhouby
 */
public abstract class BaseFragment extends Fragment implements OnClickListener {

	/** 根View **/
	protected View rootView;

	/** 获取布局资源 **/
	protected abstract int getContentView();

	/** 初始化 **/
	protected abstract void initFragment();

	@Override
	public final View onCreateView(LayoutInflater inflater,
			ViewGroup container, Bundle savedInstanceState) {
		rootView = inflater.inflate(getContentView(), container, false);
		initFragment();

		ViewGroup parent = (ViewGroup) rootView.getParent();
		if (parent != null) {
			parent.removeView(rootView);
		}

		return rootView;
	}

	/** 根据id查找View **/
	protected View findViewById(int id) {
		return rootView.findViewById(id);
	}



}
